import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:online_study/base/app_title.dart';
import 'package:online_study/mine/answer/answer_history.dart';
import 'package:online_study/mine/answer/answer_item.dart';
import 'package:online_study/mine/exam/exam_bean.dart';
import 'package:online_study/theme/colors.dart';
import 'package:online_study/theme/size.dart';

//答题结果
class AnswerResultPage extends StatefulWidget {
  @override
  _AnswerResultState createState() => _AnswerResultState();
}

class _AnswerResultState extends State<AnswerResultPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: BackButton(color: ThemeColor.color333333),
        titleSpacing: 0,
        elevation: ThemeSize.appElevation,
        backgroundColor: ThemeColor.colorWhite,
        title: AppTitle("答题结果"),
        actions: [
          GestureDetector(
            child: Container(
              alignment: Alignment.center,
              margin: EdgeInsets.only(right: ThemeSize.width19),
              child: Text("答题记录",
                  style: TextStyle(
                      color: ThemeColor.color333333, fontSize: ThemeSize.sp13)),
            ),
            onTap: () {
              Get.off(() => AnswerHistoryPage());
            },
          )
        ],
      ),
      body: SingleChildScrollView(
        child: Container(
          child: Column(
            children: [
              _buildTop(),
              Divider(
                height: ThemeSize.width1,
              ),
              ListView.separated(
                  itemBuilder: (BuildContext context, int index) {
                    var examBean = ExamBean();
                    examBean.isMulti = false;
                    examBean.correctAnswers = ["D"];
                    examBean.choiceAnswers = ["D"];
                    examBean.question = "提升自身形象的三大要素";
                    List<String> result = [
                      "A . 肢体语言",
                      "B . 着装",
                      "C . 专业技能",
                      "D . 过度饮酒"
                    ];
                    examBean.answers = result;
                    examBean.index = index + 1;
                    return AnswerItemPage(examBean);
                  },
                  separatorBuilder: (BuildContext context, int index) {
                    return Divider(height: ThemeSize.width1);
                  },
                  itemCount: 5,
                  shrinkWrap: true,
                  physics: NeverScrollableScrollPhysics())
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildTop() {
    return Container(
      padding:
          EdgeInsets.only(left: ThemeSize.width19, top: ThemeSize.height12),
      color: ThemeColor.colorWhite,
      child: Column(
        children: [
          Row(
            children: [
              Icon(Icons.check_circle,
                  color: ThemeColor.color1485EE, size: ThemeSize.height18),
              Container(
                margin: EdgeInsets.only(left: ThemeSize.width5),
                child: Text(
                  "本日答对题目数：2",
                  style: TextStyle(
                      color: ThemeColor.color333333, fontSize: ThemeSize.sp13),
                ),
              )
            ],
          ),
          Container(
            alignment: Alignment.center,
            padding: EdgeInsets.symmetric(vertical: ThemeSize.height20),
            child: Row(
              children: [
                Expanded(
                    child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    RichText(
                      text: TextSpan(
                        // style: DefaultTextStyle.of(context).style,
                        children: <InlineSpan>[
                          TextSpan(
                              text: '错题数：',
                              style: TextStyle(
                                  color: ThemeColor.color808080,
                                  fontSize: ThemeSize.sp13)),
                          TextSpan(
                              text: '0',
                              style: TextStyle(
                                  color: ThemeColor.colorRed,
                                  fontSize: ThemeSize.sp13)),
                        ],
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: ThemeSize.height12),
                      child: RichText(
                        text: TextSpan(
                          // style: DefaultTextStyle.of(context).style,
                          children: <InlineSpan>[
                            TextSpan(
                                text: '正确率：',
                                style: TextStyle(
                                    color: ThemeColor.color808080,
                                    fontSize: ThemeSize.sp13)),
                            TextSpan(
                                text: '100%',
                                style: TextStyle(
                                    color: ThemeColor.colorRed,
                                    fontSize: ThemeSize.sp13)),
                          ],
                        ),
                      ),
                    ),
                  ],
                )),
                Expanded(
                    child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Text("用时： 00:10:18",
                        style: TextStyle(
                            color: ThemeColor.color808080,
                            fontSize: ThemeSize.sp13)),
                    Container(
                      margin: EdgeInsets.only(top: ThemeSize.height12),
                      child: RichText(
                        text: TextSpan(
                          // style: DefaultTextStyle.of(context).style,
                          children: <InlineSpan>[
                            TextSpan(
                                text: '积分：',
                                style: TextStyle(
                                    color: ThemeColor.color808080,
                                    fontSize: ThemeSize.sp13)),
                            TextSpan(
                                text: '+2',
                                style: TextStyle(
                                    color: ThemeColor.colorRed,
                                    fontSize: ThemeSize.sp13)),
                          ],
                        ),
                      ),
                    ),
                  ],
                )),
              ],
            ),
          )
        ],
      ),
    );
  }
}
